package GUI;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextPane;
import javax.swing.JLabel;

import Client.BusinessImplements;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.awt.Color;
import javax.swing.LayoutStyle.ComponentPlacement;
import java.awt.SystemColor;

public class Showing_Report extends Abstract_Jpanel{
	private JPanel panel;
	private JTextArea textPane;
	private JLabel lblReport;
	private JTextArea textArea;
	private JPanel panel_1;
	public Showing_Report() {
		
		panel = new JPanel();
		GroupLayout groupLayout = new GroupLayout(this);
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addComponent(panel, GroupLayout.PREFERRED_SIZE, 549, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(86, Short.MAX_VALUE))
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addComponent(panel, GroupLayout.PREFERRED_SIZE, 474, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(31, Short.MAX_VALUE))
		);
		
		lblReport = new JLabel("Report");
		lblReport.setFont(new Font("Tahoma", Font.BOLD, 14));
		
		JButton button = new JButton("Back");
		button.setFont(new Font("Tahoma", Font.PLAIN, 14));
		
		JLabel lblReport_1 = new JLabel(" Report:");
		lblReport_1.setForeground(new Color(3, 25, 112));
		lblReport_1.setFont(new Font("MV Boli", Font.BOLD, 22));
		
		panel_1 = new JPanel();
		panel_1.setBackground(SystemColor.inactiveCaption);
		GroupLayout gl_panel = new GroupLayout(panel);
		gl_panel.setHorizontalGroup(
			gl_panel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_panel.createSequentialGroup()
					.addContainerGap()
					.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
						.addComponent(lblReport_1, GroupLayout.PREFERRED_SIZE, 217, GroupLayout.PREFERRED_SIZE)
						.addGroup(gl_panel.createSequentialGroup()
							.addGap(10)
							.addGroup(gl_panel.createParallelGroup(Alignment.TRAILING)
								.addComponent(button)
								.addComponent(panel_1, GroupLayout.PREFERRED_SIZE, 486, GroupLayout.PREFERRED_SIZE))))
					.addContainerGap(129, Short.MAX_VALUE))
		);
		gl_panel.setVerticalGroup(
			gl_panel.createParallelGroup(Alignment.TRAILING)
				.addGroup(Alignment.LEADING, gl_panel.createSequentialGroup()
					.addContainerGap()
					.addComponent(lblReport_1, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addComponent(panel_1, GroupLayout.PREFERRED_SIZE, 357, GroupLayout.PREFERRED_SIZE)
					.addGap(18)
					.addComponent(button, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(56, Short.MAX_VALUE))
		);
		
		
		//panel.add(button_1);
		textArea = new JTextArea();
	
		
		panel.setLayout(gl_panel);
		setLayout(groupLayout);
		button.addActionListener(new ActionListener() {
			 	public void actionPerformed(ActionEvent e) {
			 		Sign_in_panel sip=new Sign_in_panel();
			 		on_screen_unload();
			 		BusinessImplements.GetInstance().getMainFrame().setContentPane(sip);
			 		sip.setSize(getMaximumSize());
			 		sip.on_screen_load();
			 		
			 		
			 		
			 	}
			 });
		
	}
	
	public void displayReport(ArrayList<String> reportAnswer)
	{
 
		if(reportAnswer!=null)
		{
			for(String s : reportAnswer)  
				textArea.append(s + System.getProperty("line.separator"));  
			
			
			int max=0;
			for (int i=0 ; i < reportAnswer.size() ; i++)
				if (max < reportAnswer.get(i).length())
					max = reportAnswer.get(i).length();
	
			textArea.setBounds(10, 15, max*8, reportAnswer.size()*18);
		}
		
		
	}

	@Override
	public void next_screen() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void prev_screen() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void on_screen_load() {

		panel_1.add(textArea);
		panel.add(lblReport);
	}

	@Override
	public void on_screen_unload() {
		// TODO Auto-generated method stub
		
	}
}
